<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>admin page</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<!-- Add by Kravis Liu 2014.09.22 -->
		<link rel="stylesheet" href="/css/base.css" />
		<link rel="stylesheet" href="/css/list.css" />
		<script src="/js/av-mini.js"></script>
		<script src="/js/av.js"></script>
		<script src="/js/jquery-1.11.1.min.js"></script>
		<script type="text/javascript">
			
			function addAdmin(){
				$("#createAdminForm").submit();						
			}
			
			function deleteUser(userId){
				if(confirm("是否确定删除？")){
					$.ajax({
					   type: "POST",
					   url: "/deleteAdmin",
					   data: "userId=" + userId,
					   success: function(msg){
						 if(msg == "success"){
							 alert("操作成功！");
							 $("#"+userId).hide();			 
						 }
					   }
					});				
				}								
						
			}
			
		</script>
	</head>
	
	<body>
		<div id="page">
			<div id="header">
				<h4>后台管理</h4>
			</div>
		
			<form method="post" id="createAdminForm" action="/createAdmin">
				用户名：<input id="username" name="username" value="" type="text"/>
				密码：<input id="password" name="password" value="" type="text"/>
				<input class="change" type="button" onclick="addAdmin();" value="添加" />
			</form>
			
			<div id="content_div">
				<table width="98%" border="1" cellpadding="0" cellspacing="0">
					<tbody id="add_point">
						<tr>
							<td height="11" align="center">用户名</td>
							<td height="11" align="center" >操作</td>
						</tr>
						<% if (Users){ %>
						<% Users.forEach(function (user){ %>	
						<tr id="<%= user.id%>">
							<td><div align="center"><%= user.get('username') %></div></td>
							<td><div align="center"><a href="/deleteAdmin?userId=<%= user.id %>" >删除</a></div></td>
						</tr>
						<% })} %> 			
					</tbody>			
				</table>
			</div>
		 </div>
	</body>
</html>
